<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.autocomplete.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.mselect.js?"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.autocomplete.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	var product_categories_data = <?=$product_categories?>;
	$(document).mselect(product_categories_data, 'product_categories_id', 'product_categories_id', "<?=isset($product['product_categories_id']) ? $product['product_categories_id'] : 0?>");
	$("#preferred_provider_ajax").autocomplete("<?=url('Product::Basicinfo/ProviderAjax')?>").result(function(event, data, formatted){
		if (data['id'])
		{
			$("#preferred_provider_id").val(data['id']);
		}
		else
		{
			$("#preferred_provider_id").val('');
		}
	});
	$("#q").autocomplete("<?=url('Product::BasicInfo/ProductInfoAjax')?>").result(function(event, data, formatted){
		if (data[1])
		{
			$("#id").val(data[1]);
		}
		else
		{
			$("#id").val('');
		}
	});
});
</script>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>输查找编号</th>
	<td><input type="text" size="80" id="q" /></td>
	<td>
		<input type="hidden" name="id" id="id" value="" />
		<input type="submit" class="button" value="查询" />
	</td>
</tr>
</table>
</form>
<form action="<?=url('Product::Basicinfo/EditSave')?>" method="post" >
	<table class="form_table">
		<tr>
			<th>产品编号</th>
			<td>
				<?=isset($product['number']) ? $product['number'] : ''?>
				<input type="hidden" name="number" value="<?=isset($product['number']) ? $product['number'] : ''?>" />
			</td>
		</tr>
		<tr>
			<th>产品名称</th>
			<td>
				<input type="text" name="name" size="100" value="<?=isset($product['name']) ? htmlspecialchars($product['name']) : ''?>"/>
			</td>
		</tr>
		<tr>
		<th>产品分类</th>
			<td>
				<input type="hidden" id="product_categories_id" name="product_categories_id" />
			</td>
		</tr>
		<tr>
			<th>申报价值</th>
			<td><input type="text" name="declared_value" value="<?=$product['declared_value']?>" /></td>
		</tr>
		<tr>
			<th>申报中文名</th>
			<td><input type="text" name="declared_name_cn" value="<?=$product['declared_name_cn']?>" /></td>
		</tr>
		<tr>
			<th>申报英文名</th>
			<td><input type="text" name="declared_name_en" value="<?=$product['declared_name_en']?>" /></td>
		</tr>
		<tr>
		<th>采购价格</th>
			<td><?=$product['purchase_price']?></td>
		</tr>
		<tr>
			<th>产品重量(g)</th>
			<td><input type="text" name="weight" value="<?=isset($product['weight']) ? sprintf('%.3f', $product['weight']) : ''?>" /></td>
		</tr>
		<tr>
			<th>首选供应商</th>
			<td>
			<input type="text" id="preferred_provider_ajax" value="<?=isset($preferred_provider['id']) ? $preferred_provider['name'] : ''?>" />
			<input type="hidden" name="preferred_provider_id" id="preferred_provider_id" value="<?=isset($preferred_provider['id']) ? $preferred_provider['id'] : ''?>" />
			</td>
		</tr>
		<tr>
			<th>图片预览</th>
			<td>
				<?if ($product['pic_url']):?>
					<?$pretty_photo_number = 0;?>
					<?foreach ($product['pic_url'] as $pp):?>
					<a rel="pretty_photo[<?=$product['id']?>]" href="<?=$pp?>"><?if(!$pretty_photo_number):?><span class="img_icon"></span><?endif;?></a>
					<?$pretty_photo_number = 1;?>
					<?endforeach;?>
				<?endif;?>
			</td>
		</tr>
		<tr>
			<th>图片编辑</th>
			<td><input type="text" name="img" size="100" value="<?=$product['img']?>" /></td>
		</tr>		
		<tr>
			<th>备注</th>
			<td><textarea name="notes" rows="5" cols="30"><?=isset($product['notes']) ? $product['notes'] : ''?></textarea></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" class="button" value="保存" /></td>
		</tr>
	</table>
</form>
<?php $this->_endblock();?>